package com.billing.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.billing.persistance.dao.IGenericDAO;
import com.billing.persistance.entities.Invoice;
import com.billing.persistance.entities.BillingEntry;
import com.billing.aop.Auditable;

/**
 * Service providing CRUD methods to Invoice as well as Entry management and report creation
 * @author Victor
 *
 */
@Service
public class InvoiceServiceImpl implements InvoiceService {
    
    @Autowired
    @Qualifier(value="invoiceDAO")
    private IGenericDAO<Invoice, Long> invoiceDAO;
    
    @Auditable
    @Transactional
    public void createInvoice(Invoice invoice) {
        throw new RuntimeException("Not yet implemented");
    }
    
    @Auditable
    @Transactional
    public void deleteInvoice(Invoice invoice){
        throw new RuntimeException("Not yet implemented");
    }
    
    @Auditable
    @Transactional
    public void updateInvoice(Invoice invoice) {
        throw new RuntimeException("Not yet implemented");
    }
    
    @Transactional(readOnly = true)
    public List<Invoice> getInvoices() {
        return invoiceDAO.getList("");
    }
    
    @Auditable
    @Transactional
    public void addBillingEntryToInvoice(Invoice invoice, BillingEntry entry) {
        throw new RuntimeException("Not yet implemented");
    }
    
    @Auditable
    @Transactional
    public void removeBillingEntryFromInvoice(Invoice invoice, BillingEntry entry) {
        throw new RuntimeException("Not yet implemented");
    }

    @Transactional(readOnly = true)
    public void generateInvoiceReport(Invoice invoice){
        throw new RuntimeException("Not yet implemented");
    }

    @Transactional(readOnly = true)
    public Invoice readInvoice(Long id) {
        return invoiceDAO.read(id);
    }
}

